//高级动态墙
import * as Cesium from 'cesium'
import FlowWall from "@/threeJs/wall/FlowWall.js"
import MaterialTypes from "@/threeJs/wall/MaterialTypes.js"

let size = 1
let BigWallDataArr = [
    {
        name: '小海子产业园',
        positions: [[113.80239486694337, 41.433846822063884], [113.79878997802734, 41.42728289146282], [113.80449771881105, 41.423196187713316], [113.80964756011964, 41.42075047820218], [113.81797313690186, 41.416663363325526], [113.82209300994874, 41.41608406639095], [113.82363796234132, 41.42856998898639], [113.80239486694337, 41.433846822063884]]
    },
    {
        name: '三大顷产业园',
        positions: [[113.5540008544922, 41.46813578145238], [113.54833602905275, 41.4680714664161], [113.54988098144533, 41.45855213759244], [113.55134010314941, 41.44851673768185], [113.53692054748537, 41.4427907178444], [113.53546142578126, 41.4385441296384], [113.52790832519533, 41.43397551995129], [113.52722167968751, 41.42831257152294], [113.52335929870607, 41.42831257152294], [113.52198600769044, 41.422134246213616], [113.5261917114258, 41.42149063685283], [113.53357315063477, 41.42142627556591], [113.53400230407716, 41.42773337849849], [113.55116844177248, 41.42696111309512], [113.55185508728029, 41.443820151924825], [113.56713294982912, 41.4441418467258], [113.56704711914062, 41.46389085220665], [113.5540008544922, 41.46813578145238]]
    },
    {
        name: '七台镇西产业园',
        positions: [[113.49909067153932, 41.54250553376699], [113.4997344017029, 41.53816910903147], [113.53061199188234, 41.5369484333286], [113.52943181991579, 41.54881692122213], [113.51649284362794, 41.544769995551846], [113.51589202880861, 41.539775226171294], [113.51333856582642, 41.53935763955208], [113.51170778274538, 41.54197554189739], [113.50561380386354, 41.54014462747135], [113.50544214248659, 41.54276249795834], [113.49909067153932, 41.54250553376699]]
    },
    {
        name: '七台镇东产业园',
        positions: [[113.61013412475587, 41.55175560133369], [113.60957622528078, 41.549860730001896], [113.61305236816408, 41.548415451819324], [113.61155033111574, 41.54337278382028], [113.59386920928956, 41.54202372315594], [113.59047889709474, 41.53550286651646], [113.58193874359132, 41.53778363498268], [113.57816219329835, 41.52837093073045], [113.59670162200928, 41.52467615033536], [113.59751701354982, 41.52721432651092], [113.60730171203615, 41.52544725236142], [113.6080312728882, 41.52769624744852], [113.60258102416994, 41.53042706495603], [113.6064863204956, 41.53778363498268], [113.61601352691652, 41.53726966601039], [113.61695766448975, 41.53916490635688], [113.62069129943849, 41.53768726611149], [113.62408161163331, 41.544850294159204], [113.61661434173584, 41.547419796942286], [113.61773014068605, 41.549475325645766], [113.61013412475587, 41.55175560133369]]
    },
]

function addParkWall(cesiumViewer) {
    let ParkWallArr = []
    BigWallDataArr.forEach(item => {
        let pos = arrChange(item.positions)
        let wall = new FlowWall(
            cesiumViewer,
            Cesium.Cartesian3.fromDegreesArray(pos),
            {
                wallHeight: 600,
                wallColor: Cesium.Color.GREEN,
                duration: 1000,
                materialType: MaterialTypes.LINEFLOW,
            },
            item.name
        );
        ParkWallArr.push(wall)
    })
    return ParkWallArr
}

function arrChange(arr) {
    let newArr = []
    arr.forEach(item => {
        item.forEach(it => {
            newArr.push(it)
        })
    })
    return newArr
}

export {addParkWall}
